import DisposeBridge from '@/jsbridge/page-turns';
import {jsBridge} from '@/jsbridge/js-tool/jsbridge-tool';

const state = {

};


const getters = {
    
};

const actions = {

    /**
     * 与页面相关的处理  页面跳转处理                         /    页面标题设置    / 页面返回刷新 / 去登录
     * method:        goNewPage|goNativePage|miniprogram /   setNativeTitle  / isBack
     * name:          跳转原生页面，原生标识
     * params: 参数 这里在store里面传data参数
     * options : 标题信息参数
     * url, 跳转地址
     * isBack,  是否返回
     * isReplace, 是否返回替换
     */
    disposeBridge({
        commit,
        dispatch,
        state
    }, payload) {
        /**
         *
         let name = payload.name;
            let url = payload.url;
            let isBack = payload.isBack;
            let isReplace = payload.isReplace;
            */
        DisposeBridge.relatePage(payload);
    },

    SXYJSBridge({
        commit,
        dispatch,
        state
    }, payload) {
        let { method, fun, data, callback, sync, h5Url } = payload;
        let jsFun = method || fun;
        if (jsBridge[jsFun] ){
            jsBridge[jsFun](fun, data, callback, sync)
        } else {
            jsBridge.commonJsBridge(jsFun, data, callback, sync, h5Url);
        }
    },
};

const mutations = {
   
};

export default {
    namespaced: true,
    state,
    getters,
    actions,
    mutations
}
